import request from '@/utils/api'

export const createMedia = (mediaData) => {
  return request.post('/media', mediaData)
}

export const updateMedia = (id, mediaData) => {
  return request.put(`/media/${id}`, mediaData)
}

export const deleteMedia = (id) => {
  return request.delete(`/media/${id}`)
}

export const deleteMediaByNoteId = (noteId) => {
  return request.delete(`/media/note/${noteId}`)
}

export const getMediaById = (id) => {
  return request.get(`/media/${id}`)
}

export const getMediaByNoteId = (noteId) => {
  return request.get(`/media/note/${noteId}`)
}

export const getMediaByType = (mediaType) => {
  return request.get(`/media/type/${mediaType}`)
}

export const updateMediaOrder = (id, orderIndex) => {
  return request.patch(`/media/${id}/order`, { orderIndex })
}